/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Victor
 */
@Entity
@Table(name = "cheques")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cheques.findAll", query = "SELECT c FROM Cheques c order by c.id desc"),
    @NamedQuery(name = "Cheques.findByClienteNombre", query = "SELECT c FROM Cheques c where c.idCliente.nombrerazon like :cliente order by c.idCliente.nombrerazon, c.id desc"),
    @NamedQuery(name = "Cheques.findById", query = "SELECT c FROM Cheques c WHERE c.id = :id"),
    @NamedQuery(name = "Cheques.findByidCliente", query = "SELECT c FROM Cheques c WHERE c.idCliente.id = :idCliente"), 
    @NamedQuery(name = "Cheques.findByidClienteidCondicion", query = "SELECT c FROM Cheques c WHERE c.idCliente.id = :idCliente and c.idChequesCondicion.id = :idCondicion order by c.fechalibramiento"), 
    @NamedQuery(name = "Cheques.findByBanco", query = "SELECT c FROM Cheques c WHERE c.banco = :banco"),
    @NamedQuery(name = "Cheques.findByPlaza", query = "SELECT c FROM Cheques c WHERE c.plaza = :plaza"),
    @NamedQuery(name = "Cheques.findByFechalibramiento", query = "SELECT c FROM Cheques c WHERE c.fechalibramiento between :desde and :hasta order by c.fechalibramiento"),
    @NamedQuery(name = "Cheques.findByFechalibramientoidCondicion", query = "SELECT c FROM Cheques c WHERE c.idChequesCondicion.id = :idCondicion and c.fechalibramiento between :desde and :hasta order by c.fechalibramiento"),
    @NamedQuery(name = "Cheques.findByFechacobro", query = "SELECT c FROM Cheques c WHERE c.fechacobro between :desde and :hasta order by c.fechacobro"),
    @NamedQuery(name = "Cheques.findByFechacobroidCondicion", query = "SELECT c FROM Cheques c WHERE c.idChequesCondicion.id = :idCondicion and c.fechacobro between :desde and :hasta order by c.fechacobro"),
    @NamedQuery(name = "Cheques.findByFecha", query = "SELECT c FROM Cheques c WHERE c.fecha = :fecha"),
    @NamedQuery(name = "Cheques.findByFechaLibramientoidCliente", query = "SELECT c FROM Cheques c WHERE c.idCliente.id = :idCliente and c.fechalibramiento between :desde and :hasta order by c.fechalibramiento"),
    @NamedQuery(name = "Cheques.findByFechaCobroidCliente", query = "SELECT c FROM Cheques c WHERE c.idCliente.id = :idCliente and c.fechacobro between :desde and :hasta order by c.fechacobro"),
    @NamedQuery(name = "Cheques.findByFechaCobroLibramientoidCliente", query = "SELECT c FROM Cheques c WHERE c.idCliente.id = :idCliente and c.fechacobro between :cobrodesde and :cobrohasta and c.fechalibramiento between :libramientodesde and :libramientohasta order by c.fechacobro"),
    @NamedQuery(name = "Cheques.findByFechaLibramientoCobro", query = "SELECT c FROM Cheques c WHERE c.fechacobro between :cobrodesde and :cobrohasta and c.fechalibramiento between :libramientodesde and :libramientohasta order by c.fechacobro"),
    @NamedQuery(name = "Cheques.findByDato", query = "SELECT c FROM Cheques c where c.idCliente.nombrerazon like :cliente or c.numero like :numero or c.banco like :banco order by c.id desc"),
    @NamedQuery(name = "Cheques.findByNumero", query = "SELECT c FROM Cheques c WHERE c.numero = :numero")})
public class Cheques implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @Column(name = "banco")
    private String banco;
    @Basic(optional = false)
    @Column(name = "plaza")
    private String plaza;
    @Basic(optional = false)
    @Column(name = "fechalibramiento")
    @Temporal(TemporalType.DATE)
    private Date fechalibramiento;
    @Basic(optional = false)
    @Column(name = "fechacobro")
    @Temporal(TemporalType.DATE)
    private Date fechacobro;
    @Basic(optional = false)
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @Basic(optional = false)
    @Column(name = "numero")
    private String numero;
    @JoinColumn(name = "id_clientes", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Clientes idCliente;    
    @Basic(optional = false)
    @Column(name = "importe")
    private double importe;
    @Basic(optional = false)
    @Column(name = "estado")
    private int estado;
    @Basic(optional = true)
    @Column(name = "observaciones")
    private String observaciones;
    @JoinColumn(name = "id_cheques_condicion", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private ChequesCondicion idChequesCondicion;

    public Cheques() {
    }

    public Cheques(Integer id) {
        this.id = id;
    }

    public Cheques(Integer id, String banco, String plaza, Date fechalibramiento, Date fechacobro, Date fecha, String numero) {
        this.id = id;
        this.banco = banco;
        this.plaza = plaza;
        this.fechalibramiento = fechalibramiento;
        this.fechacobro = fechacobro;
        this.fecha = fecha;
        this.numero = numero;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getBanco() {
        return banco;
    }

    public void setBanco(String banco) {
        this.banco = banco;
    }

    public String getPlaza() {
        return plaza;
    }

    public void setPlaza(String plaza) {
        this.plaza = plaza;
    }

    public Date getFechalibramiento() {
        return fechalibramiento;
    }

    public void setFechalibramiento(Date fechalibramiento) {
        this.fechalibramiento = fechalibramiento;
    }

    public Date getFechacobro() {
        return fechacobro;
    }

    public void setFechacobro(Date fechacobro) {
        this.fechacobro = fechacobro;
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        this.fecha = fecha;
    }

    public String getNumero() {
        return numero;
    }

    public void setNumero(String numero) {
        this.numero = numero;
    }

    public Clientes getIdCliente() {
        return idCliente;
    }

    public void setIdCliente(Clientes idCliente) {
        this.idCliente = idCliente;
    }

    
    public double getImporte() {
        return importe;
    }

    public void setImporte(double importe) {
        this.importe = importe;
    }

    public int getEstado() {
        return estado;
    }

    public void setEstado(int estado) {
        this.estado = estado;
    }

    public String getObservaciones() {
        return observaciones;
    }

    public void setObservaciones(String observaciones) {
        this.observaciones = observaciones;
    }

    public ChequesCondicion getIdChequesCondicion() {
        return idChequesCondicion;
    }

    public void setIdChequesCondicion(ChequesCondicion idChequesCondicion) {
        this.idChequesCondicion = idChequesCondicion;
    }
    
    
    
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cheques)) {
            return false;
        }
        Cheques other = (Cheques) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entities.Cheques[ id=" + id + " ]";
    }
    
}
